package games.tetris;

import hardware.Display2D;
import hardware.UI;

public class Tetris {

	

public boolean demo()
{

	while(true)
	{
		
		
		
		
	if (UI.keyRUp())
		return(true);
	
	if (UI.keyRDown())
		return(false);
	
	}
}
	



public void play() throws InterruptedException
{
	int tmpCounter;
	int level;
	
	int xPos;
	int yPos;

	
	

	level=0;
	
	
	while(true)
		{

		if (UI.keyLUp())
			{
			
		//	prepareLevel();
			if (playLevel(level)==true)
				{
		//		levelWin();
				level++;
				}
			else
				{
		//		levelLoose();
				level=0;
				}
			}
		Display2D.clear();

		xPos=0;
		yPos=0;

		
		for (tmpCounter=0;tmpCounter<level;tmpCounter++)
			{
			Display2D.setPixel((byte)xPos,(byte) yPos, (short)0xf0);
			
			xPos++;
			 if (xPos>=Display2D.getColumnCount())
			 	{
				 xPos=0;
				 yPos++;
			 	}
			 if (yPos>=Display2D.getRowCount())
			 	{
				 xPos=0;
				 yPos=0;
			 	}			
			}

		
		if (UI.keyLDown())
			return;
		
		Display2D.doRepaint();
		Thread.sleep(10);
		
		}
	
}
	


public boolean playLevel(int level)
{

	
	
	return(false);
}



}
